package com.example.actearly_revised;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class LoginVerify {

	public static String parentNameS = "";
	public static String getParentNameS() {
		return parentNameS;
	}

	public static String getDoctorNameS() {
		return doctorNameS;
	}

	public static String getDateOfBirthS() {
		return dateOfBirthS;
	}

	public static String getEmailS() {
		return emailS;
	}

	public static String getChildNameS() {
		return childNameS;
	}

	public static String getDoctorsEmailS(){
		return docEmailS;
	}
	
	public static int getGenderS(){
		return genderS;
	}
	
	public static String doctorNameS = "";
	public static String dateOfBirthS = "";
	public static String emailS = "";
	public static String childNameS = "";
	//public static String childNam = "";
	public static String docEmailS = "";
	public static int genderS = -1;
	
	public static void setUserInfo(String childName, String doctorName, String email, String parentName, String dateOfBirth, String docEmail, int gender){
		doctorName=doctorName.replaceAll("dr. ","");
		doctorName=doctorName.replaceAll("Dr. ","");
		doctorName=doctorName.replaceAll("doctor ","");
		doctorName=doctorName.replaceAll("Doctor ","");
		doctorName=doctorName.replaceAll("dr ","");
		doctorName=doctorName.replaceAll("Dr ","");
		childNameS = childName;
		doctorNameS = doctorName;
		emailS = email;
		parentNameS = parentName;
		dateOfBirthS = dateOfBirth;
		docEmailS = docEmail;
		genderS = gender;
	}
	
	public static boolean verifyDoctorEmail(String demail){
	    Pattern pattern = Pattern.compile("\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b");
	    Matcher matcher = pattern.matcher(demail);
	    if (matcher.find()){
	      return true; 
	    } 
	    return false; 
	}
	
	public static boolean verifyGender(int gender){
		if(gender == 1 || gender == 2)
			return true;
		else
			return false;
	}
	
	public static boolean verifyChildName(String childName){
		System.out.println("////" + childName);
		if(childName == "" || childName == null || childName.isEmpty()){
			System.out.println("false");
			return false;
		}
		System.out.println("true");
		return true;
	}
	
	public static boolean verifyPaentName(String parentName){
		if(parentName == ""|| parentName == null || parentName.isEmpty()){
			return false;
		}
		return true;
	}
	
	public static boolean verifyDoctorName(String doctorName){
		if(doctorName == ""|| doctorName == null || doctorName.isEmpty()){
			return false;
		}
		return true;
	}
	
	public static boolean verifyEmail(String email){
		if(email == ""){
			return false;
		}
		
		return email(email);
	}
	
	  public static boolean email(String s){
		    Pattern pattern = Pattern.compile("\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b");
		    Matcher matcher = pattern.matcher(s);
		    if (matcher.find()){
		      return true; 
		    } 
		    return false; 
		  }
}